package com.gitee.Transformation

import org.apache.flink.api.java.aggregation.Aggregations
import org.apache.flink.api.scala.ExecutionEnvironment

/*
  聚合操作,可以求最大值,最小值,总和等等

  太垃圾了,居然没有求平均值得方法
 */
object AggregateTest {
  def main(args: Array[String]): Unit = {
    val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
    import org.apache.flink.api.scala._
    env.setParallelism(1)
    case class User(id: String, name: String)
    val lineData: DataSet[(String, Int)] = env.fromElements(("java",1),("jva",1),("java",1))

    val groupData: GroupedDataSet[(String, Int)] = lineData.groupBy(0)

    groupData.aggregate(Aggregations.SUM,1).print()
  }

}
